﻿namespace GFramework.Netwrok
{
    public abstract class NetChannel : Composite, INetChannel
    {
        protected NetService NetService {
            get
            {
                return Get<NetService>();
            }
        }

        public string Name { get; set; }

        public bool Connected { get { return NetService.Connected; } }
        
        public void Accept(string address)
        {
            NetService?.Accept(address);
        }

        public override void Clear()
        {
            NetService?.Dispose();
        }

        public void Close()
        {
            NetService?.Close();
        }

        public void Connect(string address)
        {
            NetService?.Connect(address);
        }

        public void RegisterHandler(IMessageHandler handler)
        {

        }

        public void Send<T>(T packet) where T : IMessage
        {

        }
    }
}
